class Comment {
  final String id;
  final String mid;
  final String cover;
  final String uid;
  final String username;
  final String replyName;
  final String replyContent;
  final String avatar;
  final String pid;
  final String replyUid;
  final String replyId;
  final int level;
  final int sort;
  final String content;
   String count;
  final List<Comment> childrenComments;
  final int createDate;
   bool isAgree;
  final String twoNums;

  Comment({
    this.id = '',
    this.mid = '',
    this.cover = '',
    this.uid = '',
    this.username = '',
    this.replyName = '',
    this.replyContent = '',
    this.avatar = '',
    this.pid = '',
    this.replyUid = '',
    this.replyId = '',
    this.level = 0,
    this.sort = 0,
    this.content = '',
    this.count = '0',
    this.childrenComments = const [],
    this.createDate = 0,
    this.isAgree = false,
    this.twoNums = '',
  });

  factory Comment.fromJson(Map<String, dynamic> json) {
    return Comment(
      id: json['id'] ?? '',
      mid: json['mid'] ?? '',
      cover: json['cover'] ?? '',
      uid: json['uid'] ?? '',
      username: json['username'] ?? '',
      replyName: json['replyName'] ?? '',
      replyContent: json['replyContent'] ?? '',
      avatar: json['avatar'] ?? '',
      pid: json['pid'] ?? '',
      replyUid: json['replyUid'] ?? '',
      replyId: json['replyId'] ?? '',
      level: json['level'] ?? 0,
      sort: json['sort'] ?? 0,
      content: json['content'] ?? '',
      count: json['count'] ?? 0,
      childrenComments: json['childrenComments']?.map<Comment>((e) => Comment.fromJson(e)).toList() ?? const [],
      createDate: json['createDate'] ?? 0,
      isAgree: json['isAgree'] ?? false,
      twoNums: json['twoNums'] ?? '',
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['mid'] = this.mid;
    data['cover'] = this.cover;
    data['uid'] = this.uid;
    data['username'] = this.username;
    data['replyName'] = this.replyName;
    data['replyContent'] = this.replyContent;
    data['avatar'] = this.avatar;
    data['pid'] = this.pid;
    data['replyUid'] = this.replyUid;
    data['replyId'] = this.replyId;
    data['level'] = this.level;
    data['sort'] = this.sort;
    data['content'] = this.content;
    data['count'] = this.count;
    data['childrenComments'] = this.childrenComments.map<dynamic>((e) => e.toJson()).toList();
    data['createDate'] = this.createDate;
    data['isAgree'] = this.isAgree;
    data['twoNums'] = this.twoNums;
    return data;
  }
}
class CommentList {
  int? pageCurrent;
  int? pageSize;
  int? total;
  bool? hasNext;
  int? pages;
  final List<Comment> comments;

  CommentList({required this.comments});

  factory CommentList.fromJson(Map<String, dynamic> json) {

    List<Comment> commentList = json['records'].map<Comment>((e) => Comment.fromJson(e)).toList();
    return CommentList(comments: commentList);
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['records'] = this.comments.map<dynamic>((e) => e.toJson()).toList();
    return data;
  }
}
